package com.itheima.reggie.exception;

import com.itheima.reggie.common.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author:YZN
 * @date:2022/12/29
 * @description:
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandle {

    @ExceptionHandler(Exception.class)
    public R exceptionAdvice(Exception ex){
       log.error("出现的异常是:{}",ex.getMessage());
       return R.error(ex.getMessage());
    }
}
